﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using Wechat.API.Filter;
using Wechat.Manager;
using Wechat.Util.ReturnMessage;
using Wechat.Util.StateCode;

namespace Wechat.API.Controllers
{
    [RoutePrefix("api/token"), UnUserAuthorize]
    public class TokenController : ApiController
    {
        public IWechatTokenManager WechatTokenManager { get; set; }
        [Route("gettoken"),HttpGet]
        public ResultMessage GetToken()
        {
            ResultMessage resultMsg = new ResultMessage()
            {
                Status = false,
                Message = "查询失败",
                Code = (int)EnumApiStateCode.SystemError,
            };
            var pageData = WechatTokenManager.GetAccessToken();
            if (pageData != null)
            {
                resultMsg.Status = true;
                resultMsg.Data = pageData;
                resultMsg.Code = (int)EnumApiStateCode.Success;
                resultMsg.Message = "查询成功";
            }
            return resultMsg;
        }
    }
}
